class Task31:
    def run(self, list1, list2):
        stack = [list1[0]]
        index = 1
        for expected_item in list2:
            while expected_item != stack[-1]:
                if index >= len(list1):
                    return False
                stack.append(list1[index])
                index += 1
            stack.pop()
        return True
